home *** CD-ROM | disk | FTP | other *** search
- ELF(3E) Last changed: 9-22-98
-
-
- NNAAMMEE
- eellff - Object file access library
-
- SSYYNNOOPPSSIISS
- cccc [_f_l_a_g ...] _f_i_l_e ... --lleellff [_l_i_b_r_a_r_y ...]
-
- ##iinncclluuddee <<lliibbeellff..hh>>
-
- IIMMPPLLEEMMEENNTTAATTIIOONN
- IRIX systems
-
- DDEESSCCRRIIPPTTIIOONN
- Functions in the ELF access library let a program manipulate ELF
- (Executable and Linking Format) object files, archive files, and
- archive members. The header file provides type and function
- declarations for all library services.
-
- Programs communicate with many of the higher-level routines using an
- ELF descriptor. That is, when the program starts working with a file,
- eellff__bbeeggiinn creates an ELF descriptor through which the program
- manipulates the structures and information in the file. These ELF
- descriptors can be used both to read and to write files. After the
- program establishes an ELF descriptor for a file, it may then obtain
- section descriptors to manipulate the sections of the file (see the
- eellff__ggeettssccnn(3E) man page). Sections hold the bulk of an object file's
- real information, such as text, data, the symbol table, and so on. A
- section descriptor belongs to a particular ELF descriptor, just as a
- section "belongs" to a file. Finally, data descriptors are available
- through section descriptors, allowing the program to manipulate the
- information associated with a section. A data descriptor "belongs" to
- a section descriptor.
-
- Descriptors provide private handles to a file and its pieces. In
- other words, a data descriptor is associated with one section
- descriptor, which is associated with one ELF descriptor, which is
- associated with one file. Although descriptors are private, they give
- access to data that may be shared. Consider programs that combine
- input files, using incoming data to create or update another file.
- Such a program might get data descriptors for an input and an output
- section. It then could update the output descriptor to reuse the
- input descriptor's data. That is, the descriptors are distinct, but
- they could share the associated data bytes. This sharing avoids the
- space overhead for duplicate buffers and the performance overhead for
- copying data unnecessarily.
-
- FFIILLEE CCLLAASSSSEESS
- ELF provides a framework in which to define a family of object files,
- supporting multiple processors and architectures. An important
- distinction among object files is the class, or capacity, of the file.
- The 32-bit class supports architectures in which a 32-bit object can
- represent addresses, file sizes, etc., as in the following:
-
- Name Purpose
-
- Elf32_Addr Unsigned address
-
- Elf32_Half Unsigned medium integer
-
- Elf32_Off Unsigned file offset
-
- Elf32_Sword Signed large integer
-
- Elf32_Word Unsigned large integer
-
- unsigned char Unsigned small integer
-
- Other classes will be defined as necessary, to support larger (or
- smaller) machines. Some library services deal only with data objects
- for a specific class, while others are class-independent. To make
- this distinction clear, library function names reflect their status,
- as described below.
-
- DDAATTAA RREEPPRREESSEENNTTAATTIIOONNSS
- Conceptually, two parallel sets of objects support cross compilation
- environments. One set corresponds to file contents, while the other
- set corresponds to the native memory image of the program manipulating
- the file. Type definitions supplied by the header files work on the
- native machine, which may have different data encodings (size, byte
- order, etc.) than the target machine. Although native memory objects
- should be at least as big as the file objects (to avoid information
- loss), they may be bigger if that is more natural for the host
- machine.
-
- Translation facilities exist to convert between file and memory
- representations. Some library routines convert data automatically,
- while others leave conversion as the program's responsibility. Either
- way, programs that create object files must write file-typed objects
- to those files; programs that read object files must take a similar
- view. See the eellff__xxllaattee(3E) and eellff__ffssiizzee(3E) man pages for more
- information.
-
- Programs may translate data explicitly, taking full control over the
- object file layout and semantics. If the program prefers not to have
- and exercise complete control, the library provides a higher-level
- interface that hides many object file details. eellff__bbeeggiinn and related
- functions let a program deal with the native memory types, converting
- between memory objects and their file equivalents automatically when
- reading or writing an object file.
-
- EELLFF VVEERRSSIIOONNSS
- Object file versions allow ELF to adapt to new requirements. Three-
- independent-versions can be important to a program. First, an
- application program knows about a particular version by virtue of
- being compiled with certain header files. Second, the access library
- similarly is compiled with header files that control what versions it
- understands. Third, an ELF object file holds a value identifying its
- version, determined by the ELF version known by the file's creator.
- Ideally, all three versions would be the same, but they may differ.
-
- If a program's version is newer than the access library, the
- program might use information unknown to the library. Translation
- routines might not work properly, leading to undefined behavior.
- This condition merits installing a new library.
-
- The library's version might be newer than the program's and the
- file's. The library understands old versions, thus avoiding
- compatibility problems in this case.
-
- Finally, a file's version might be newer than either the program or
- the library understands. The program might or might not be able to
- process the file properly, depending on whether the file has extra
- information and whether that information can be safely ignored.
- Again, the safe alternative is to install a new library that
- understands the file's version.
-
- To accommodate these differences, a program must use eellff__vveerrssiioonn to
- pass its version to the library, thus establishing the "working
- version" for the process. Using this, the library accepts data from
- and presents data to the program in the proper representations. When
- the library reads object files, it uses each file's version to
- interpret the data. When writing files or converting memory types to
- the file equivalents, the library uses the program's working version
- for the file data.
-
- SSYYSSTTEEMM SSEERRVVIICCEESS
- As previously mentioned, eellff__bbeeggiinn and related routines provide a
- higher-level interface to ELF files, performing input and output on
- behalf of the application program. These routines assume a program
- can hold entire files in memory, without explicitly using temporary
- files. When reading a file, the library routines bring the data into
- memory and perform subsequent operations on the memory copy. Programs
- that wish to read or write large object files with this model must
- execute on a machine with a large process virtual address space. If
- the underlying operating system limits the number of open files, a
- program can use eellff__ccnnttll to retrieve all necessary data from the file,
- allowing the program to close the file descriptor and reuse it.
-
- Although the eellff__bbeeggiinn interfaces are convenient and efficient for
- many programs, they might be inappropriate for some. In those cases,
- an application may invoke the eellff__xxllaattee data translation routines
- directly. These routines perform no input or output, leaving that as
- the application's responsibility. By assuming a larger share of the
- job, an application controls its input and output model.
-
- LLIIBBRRAARRYY NNAAMMEESS
- Names associated with the library take several forms:
-
- eellff__ _n_a_m_e These class-independent names perform some service,
- _n_a_m_e, for the program.
-
- eellff3322___n_a_m_e Service names with an embedded class, 3322 here,
- indicate they work only for the designated class of
- files.
-
- EEllff___T_y_p_e Data types can be class-independent as well,
- distinguished by _T_y_p_e.
-
- EEllff3322___T_y_p_e Class-dependent data types have an embedded class
- name, 3322 here.
-
- EELLFF__CC___C_M_D Several functions take commands that control their
- actions. These values are members of the EEllff__CCmmdd
- enumeration; they range from zero through
- EELLFF__CC__NNUUMM--11.
-
- EELLFF__FF___F_L_A_G Several functions take flags that control library
- status and/or actions. Flags are bits that may be
- combined.
-
- EELLFF3322__FFSSZZ___T_Y_P_E These constants give the file sizes in bytes of the
- basic ELF types for the 32-bit class of files. See
- eellff__ffssiizzee for more information.
-
- EELLFF__KK___K_I_N_D The function eellff__kkiinndd identifies the _K_I_N_D of file
- associated with an ELF descriptor. These values are
- members of the EEllff__KKiinndd enumeration; they range from
- zero through EELLFF__KK__NNUUMM--11.
-
- EELLFF__TT___T_Y_P_E When a service function, such as eellff__xxllaattee, deals
- with multiple types, names of this form specify the
- desired _T_Y_P_E. Thus, for example, EELLFF__TT__EEHHDDRR is
- directly related to EEllff3322__EEhhddrr. These values are
- members of the EEllff__TTyyppee enumeration; they range from
- zero through EELLFF__TT__NNUUMM--11.
-
- NNOOTTEESS
- The standard SVR4 eellff man page mentions processor-dependent header
- files with names of the form <<ssyyss//eellff___N_A_M_E..hh>> where _N_A_M_E is a
- processor name in a table, such as MM3322. There are no such header
- files in _I_R_I_X.
-
- A 32-bit application can construct 64-bit binaries using functions
- defined on the above-mentioned man pages. However the man pages and
- certain books published on SVR4 specifically document fields in the
- EEllff__DDaattaa structure as lloonngg. This restricts the generated object files
- (even 64-bit object files) to have 32-bit values at most when
- constructed by a 32-bit application. The resulting object file is
- always 64-bit clean (the documented 32-bit fields are only too small
- during construction of the object file, not too small in the object
- file itself). This matters, for example, in the Fortran compiler
- where the bbssss section might need to be greater than 32-bits. See
- //uussrr//iinncclluuddee//lliibbeellff..hh for the definition(s) of EEllff__DDaattaa.
-
- To overcome this difficulty, the generating application should be
- compiled with the preprocessor flag __LLIIBBEELLFF__XXTTNNDD__6644 defined to all
- compilation units and should link to --lleellff__xxttnndd and --llddwwaarrff__xxttnndd
- instead of --lleellff and --llddwwaarrff. If this is done, the definition of the
- fields in the EEllff__DDaattaa changes to 64 bits. This change permeates the
- definition of an EEllff ** (even though the definition of EEllff** is opaque
- to the application), requiring the application build to be completely
- consistent and define __LLIIBBEELLFF__XXTTNNDD__6644 everywhere in the application
- build and to link with --lleellff__xxttnndd and --llddwwaarrff__xxttnndd instead of --lleellff
- and --llddwwaarrff.
-
- It is just possible that by compiling with __LLIIBBEELLFF__XXTTNNDD__6644 visible in
- some compilation units but not others an application could manage to
- pass an EEllff** or other libelf structure created without __LLIIBBEELLFF__XXTTNNDD__6644
- into a libelf function call compiled with __LLIIBBEELLFF__XXTTNNDD__6644. Or vice-
- versa. The result will surely be chaos.
-
- __LLIIBBEELLFF__XXTTNNDD__6644 is irrelevant to any 64-bit application and the
- --lleellff__xxttnndd and --llddwwaarrff__xxttnndd are not needed, since 64-bit applications
- can build true 64-bit object files without defining __LLIIBBEELLFF__XXTTNNDD__6644.
-
- Applications which only read 64-bit object files need not use
- __LLIIBBEELLFF__XXTTNNDD__6644 since the section headers, program headers, and data
- of the file have 64-bit fields without __LLIIBBEELLFF__XXTTNNDD__6644 being defined.
-
- SSEEEE AALLSSOO
- eellff__bbeeggiinn(3E), eellff__ccnnttll(3E), eellff__eenndd(3E), eellff__eerrrroorr(3E), eellff__ffiillll(3E),
- eellff__ffllaagg(3E), eellff__ffssiizzee(3E), eellff__ggeettaarrhhddrr(3E), eellff__ggeettaarrssyymm(3E),
- eellff__ggeettbbaassee(3E), eellff__ggeettddaattaa(3E), eellff__ggeetteehhddrr(3E), eellff__ggeettiiddeenntt(3E),
- eellff__ggeettpphhddrr(3E), eellff__ggeettssccnn(3E), eellff__ggeettsshhddrr(3E), eellff__hhaasshh(3E),
- eellff__kkiinndd(3E), eellff__nneexxtt(3E), eellff__rraanndd(3E), eellff__rraawwffiillee(3E),
- eellff__ssttrrppttrr(3E), eellff__uuppddaattee(3E), eellff__vveerrssiioonn(3E), eellff__xxllaattee(3E),
- aa..oouutt(4) aarr(4)
- The chapter "Object Files" in _U_N_I_X _S_Y_S_T_E_M _V _R_E_L_E_A_S_E _4 _P_r_o_g_r_a_m_m_e_r'_s
- _G_u_i_d_e: _A_N_S_I _C _a_n_d _P_r_o_g_r_a_m_m_i_n_g _S_u_p_p_o_r_t _T_o_o_l_s, published by Prentice
- Hall, ISBN 0-13-933706-7
-
- This man page is available only online.
-
-